/*******************************************************************************
 *
 *      Filename: Image.h
 *   Description: Image class. Used to manage (load, save, transform, etc.)
 *                images (
 *        Author: [kb]ypp
 *    Created at: October 14, 2005
 * Last modified: November 26, 2005
 *
 ******************************************************************************/

#ifndef IMAGE_H
#define IMAGE_H

#include <fstream>
#include <string>

//! @brief Image class.
//!
//! Used to manage (load, save, transform, etc.) images.
//! Exception safe.
class Image {
public:
	//! @brief Specifies the number of color components in the image
	enum Format {
		eNone           = 0, //!< Image is empty (no data)
		eLuminance      = 1, //!< Grayscale image
		eLuminanceAlpha = 2, //!< Grayscale image with alpha channel
		eRGB            = 3, //!< Color image
		eRGBA           = 4  //!< Color image with alpha channel
	};

	Image();
	Image( const Image& );
	explicit Image( const std::string &filename );
	virtual ~Image();
	const Image& operator=( const Image& );

	void load( const std::string &filename );
	void save( const std::string &filename );

	int width() const;
	int height() const;
	Format format() const;
	const unsigned char* data() const;

private:
	/*void load_jpeg( const std::string &filename );
	void save_jpeg( const std::string &filename );
	void load_png( const std::string &filename );
	void save_png( const std::string &filename );*/
	void load_tga( const std::string &filename );
	void save_tga( const std::string &filename );
	void load_ppm( const std::string &filename );
	void save_ppm( const std::string &filename );
	//! @brief Clean up image
	void clean();

	struct ImageImpl;
	ImageImpl *impl;
	/*int width;  //!< Width of stored image
	int height; //!< Height of stored image
	Format components; //!< Number of color components
	unsigned char *data;   //!< Image data*/
};

#endif // IMAGE_H
